
//
//  UIImage+Extension.swift
//  微博
//
//  Created by lixiangzhou on 16/3/8.
//  Copyright © 2016年 lxz. All rights reserved.
//

import UIKit

extension UIImage {
    class func pixImageWithColor(color: UIColor) -> UIImage {
        let scale = UIScreen.mainScreen().scale
        let size = CGSize(width: 1.0 / scale, height: 1.0 / scale)
        UIGraphicsBeginImageContextWithOptions(size, false, scale)
        
        color.setFill()
        UIRectFill(CGRect(origin: CGPointZero, size: size))
        
        let result = UIGraphicsGetImageFromCurrentImageContext()
        
        UIGraphicsEndImageContext()
        
        return result
    }
    
    /// 根据颜色创建一个 点 图
    class func dotImageWithColor(color: UIColor) -> UIImage {
        let size = CGSize(width: 1, height: 1)
        UIGraphicsBeginImageContextWithOptions(size, false, UIScreen.mainScreen().scale)
        
        color.setFill()
        UIRectFill(CGRect(origin: CGPointZero, size: size))
        
        let result = UIGraphicsGetImageFromCurrentImageContext()
        
        UIGraphicsEndImageContext()
        
        return result
    }
}
